#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cstring>
#define endl "\n"
using namespace std;
int va[10000];
int main()
{
	vector<string> v;
	int n, N, k = 0;
	string a;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a;
		v.push_back(a);
	}
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> a;
		for (int j = 0; j < n; j++)
		{

			if (a == v[j])
			{
				if (va[j] == 0)
				{
					cout << "OK" << endl;
				}
				else
					cout << "REPEAT" << endl;
				va[j]++;
				k++;
				break;
			}
		}
		if (k == 0)
			cout << "WRONG" << endl;
		k = 0;
	}
	return 0;
}